<?php
defined('OA_LIB_PATH') || define('OA_LIB_PATH', '/opt/op/OALib');
defined('OPEN_LIB_PATH') || define('OPEN_LIB_PATH', '/opt/op/OpenLib');

require_once 'PHPUnit/Framework.php';
require_once 'Log.php';
require_once OPEN_LIB_PATH . '/open/models/OaDeveloperModel.php';

class OaDeveloperModelTest extends PHPUnit_Framework_TestCase
{
    private $_logger;
    private $_model;
    
    protected function setUp()
    {
        $logger = Log::factory('console');
        $logger->setMask(Log::MAX(PEAR_LOG_DEBUG));
        $this->_logger = $logger;
        $this->_model = new OaDeveloperModel($logger);
    }
    
    protected function tearDown()
    {
        
    }
    
    /**
     * @dataProvider provider
     */
    public function testCreateDeveloper($developerId)
    {
        $this->markTestSkipped();
        $result = $this->_model->createDeveloper($developerId, '王家军', array(
            'email' => 'jaggerwang@gmail.com',
            'mobile' => '13816395570'
        ));
        $this->assertTrue($result);
    }
    
    /**
     * @dataProvider provider
     */
    public function testGetDeveloper($developerId)
    {
        $this->markTestSkipped();
        $result = $this->_model->getDeveloper($developerId);
        $this->_logger->log($result, PEAR_LOG_DEBUG);
        $this->assertTrue(is_array($result));
    }
    
    /**
     * @dataProvider provider
     */
    public function testModifyDeveloper($developerId)
    {
        $this->markTestSkipped();
        $result = $this->_model->modifyDeveloper($developerId, array(
        	'name' => 'Jagger Wang'
        ));
        $this->assertTrue($result);
    }
    
    /**
     * @dataProvider provider
     */
    public function testGetBelongToCompanys($developerId)
    {
        $this->markTestSkipped();
        $result = $this->_model->getBelongToCompanys($developerId);
        $this->_logger->log($result, PEAR_LOG_DEBUG);
        $this->assertTrue(is_array($result));
    }
    
    /**
     * @dataProvider provider
     */
    public function testGetCreatedCompanys($developerId)
    {
        $this->markTestSkipped();
        $result = $this->_model->getCreatedCompanys($developerId);
        $this->_logger->log($result, PEAR_LOG_DEBUG);
        $this->assertTrue(is_array($result));
    }
    
    /**
     * @dataProvider provider
     */
    public function testAddTestAccount($developerId)
    {
        $this->markTestSkipped();
        $result = $this->_model->addTestAccount('jaggerwang@gmail.com', $developerId);
        $this->assertTrue($result);
    }
    
    /**
     * @dataProvider provider
     */
    public function testGetMyAddedTestAccounts($developerId)
    {
        $this->markTestSkipped();
        $result = $this->_model->getMyAddedTestAccounts($developerId);
        $this->_logger->log($result, PEAR_LOG_DEBUG);
        $this->assertTrue($result !== false);
    }
    
    /**
     * @dataProvider provider
     */
    public function testGetMyApps($developerId)
    {
        $this->markTestSkipped();
        $result = $this->_model->getMyApps($developerId);
        $this->_logger->log($result, PEAR_LOG_DEBUG);
        $this->assertTrue($result !== false);
    }
    
    /**
     * @dataProvider accountProvider
     */
    public function testConvertId($account)
    {
//        $this->markTestSkipped();
        $result = User::convertId($account);
        $this->_logger->log($result, PEAR_LOG_DEBUG);
        $this->assertTrue($result[0] == 0);
    }
    
    public function provider()
    {
        return array(
            array(1109246810)
        );
    }
    
    public function accountProvider()
    {
        return array(
            array('794123477'),
            array('jaggerwang'),
            array('1109442007'),
            array('1109442007.sdo'),
            array('jaggerwang@gmail.com'),
            array('13816395570'),
            array('13816395570.sdo'),
            array('dixuenong@snda.com'),
        );
    }
}
